<?php

/**
 * sfGuardUser form.
 *
 * @package    form
 * @subpackage sf_guard_user
 * @version    SVN: $Id: sfGuardUserForm.class.php 13001 2008-11-14 10:45:32Z noel $
 */
class myProfileForm extends BasesfGuardUserForm
{
  protected
    $pkName = null;

  public function configure()
  {
    parent::configure();
   


    unset(
      $this['last_login'],
      $this['created_at'],
      $this['salt'],
      $this['gender'],
      $this['email'],
      $this['algorithm'],   
      $this['is_active'],
      $this['is_super_admin'],
      $this['sf_guard_user_group_list'],
      $this['sf_guard_user_permission_list']
    );
    
     $lang = array('ru','en');
    
     $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'nickname'        => new sfWidgetFormInput(array(),array('size'=>25)),
      'username'        => new sfWidgetFormInputHidden(array(),array('size'=>25)),
      'password'        =>   new sfWidgetFormInputPassword(),
      
      	
     ));
     
     
		 	/*
		 	 * примеры виджетов
		 	 */ 
		 	//$this->widgetSchema['zodiac'] = new sfWidgetFormChoice(array('expanded'=>true,'choices' => myTools::getZodiac()));
		 	//$this->widgetSchema['zodiac2'] = new sfWidgetFormChoice(array('expanded'=>false,'choices' => myTools::getZodiac()));
		 	//$this->widgetSchema['zodiac3'] = new sfWidgetFormChoice(array('multiple'=>true,'expanded'=>false,'choices' => myTools::getZodiac()));
		 	//$this->widgetSchema['zodiac4'] = new sfWidgetFormChoice(array('multiple'=>false,'expanded'=>false,'choices' => myTools::getZodiac()));
     
     
          if(sfConfig::get('app_form_pf_account')==true)
		 {
		 	//$this->widgetSchema['account'] = new sfWidgetFormInput(array(),array('size'=>25));
		 }
     
  		 if(sfConfig::get('app_form_pf_nickname')==true)
		 {
		 	$this->widgetSchema['nickname'] = new sfWidgetFormInput(array(),array('size'=>25));
		 }   
		 
		 if(sfConfig::get('app_form_pf_birthday')==true)
		 {
		 	$this->widgetSchema['birthday'] = new sfWidgetFormI18nDate(array('culture' =>sfContext::getInstance()->getUser()->getCulture(),'years' => sfContext::getInstance()->getUser()->getYears()));
		 }
		       
      	 if(sfConfig::get('app_form_pf_height')==true)
		 {
		 	$this->widgetSchema['height'] = new sfWidgetFormInput(array(),array('size'=>5));
		 }
		 
      	 if(sfConfig::get('app_form_pf_ves')==true)
		 {
		 	$this->widgetSchema['ves'] = new sfWidgetFormInput();
		 }		 
		 
		  
       		if(sfConfig::get('app_form_pf_city')==true)
		 {
		 	$this->widgetSchema['city'] = new sfWidgetFormInput(array(),array('size'=>5));
		 }		
  		 if(sfConfig::get('app_form_pf_country')==true)
		 {
		 	$this->widgetSchema['country'] = new sfWidgetFormI18nSelectCountry(array('culture' =>sfContext::getInstance()->getUser()->getCulture()));
		 }      
      		  if(sfConfig::get('app_form_pf_astrology_sign')==true)
		 {
		 	$this->widgetSchema['astrology_sign'] = new sfWidgetFormInput(array(),array('size'=>25));
		 }		 
		 
    		  if(sfConfig::get('app_form_pf_zodiac')==true)
		 {
			$this->widgetSchema['zodiac'] = new sfWidgetFormChoice(array('expanded'=>false,'choices' => myTools::getZodiac()));		 	
		 }		 
         if(sfConfig::get('app_form_pf_eye_color')==true)
		 {
		 	//$this->widgetSchema['eye_color'] = new sfWidgetFormChoice(array('expanded'=>'true','choices' => myTools::getEyeColor()));
		 	$this->widgetSchema['eye_color'] = new sfWidgetFormInput(array(),array('size'=>25));
		 } 
		 if(sfConfig::get('app_form_pf_hair_color')==true)
		 {
		 	//$this->widgetSchema['hair_color'] = new sfWidgetFormChoice(array('expanded'=>'true','choices' => myTools::getHairColor()));
		 	$this->widgetSchema['hair_color'] = new sfWidgetFormInput(array(),array('size'=>25));
		 } 
		 
		 if(sfConfig::get('app_form_pf_hair_lenght')==true)
		 {
		 	$this->widgetSchema['hair_lenght'] = new sfWidgetFormChoice(array('expanded'=>false,'choices' => myTools::getHairleng()));
		 } 
		 if(sfConfig::get('app_form_pf_hair_type')==true)
		 {
		 	$this->widgetSchema['hair_type'] = new sfWidgetFormChoice(array('expanded'=>false,'choices' => myTools::getHairtype()));
		 } 
		 
		 
  		 if(sfConfig::get('app_form_pf_religion')==true)
		 {
		 	$this->widgetSchema['religion'] = new sfWidgetFormChoice(array('expanded'=>false,'choices' => myTools::getReligion()));
		 }
    	 if(sfConfig::get('app_form_pf_language')==true)
		 {
		 	$this->widgetSchema['language'] = new sfWidgetFormI18nSelectLanguage(array('culture' => sfContext::getInstance()->getUser()->getCulture(),'languages'=>$lang));
		 } 		 
    		  if(sfConfig::get('app_form_pf_drinking')==true)
		 {
		 	$this->widgetSchema['drinking'] = new sfWidgetFormInputCheckbox();
		 }
    		  if(sfConfig::get('app_form_pf_smoking')==true)
		 {
		 	$this->widgetSchema['smoking'] = new sfWidgetFormInputCheckbox();
		 }
		 
            if(sfConfig::get('app_form_pf_profession')==true)
		 {
		 	$this->widgetSchema['profession'] = new sfWidgetFormChoice(array('choices' => myTools::getProfession()));
		 	
		 }	 
  		 if(sfConfig::get('app_form_pf_is_marital')==true)
		 {
		 	$this->widgetSchema['is_marital'] = new sfWidgetFormChoice(array('expanded'=>false,'choices' => myTools::getIsmarital()));
		 }
    	 if(sfConfig::get('app_form_pf_have_child')==true)
		 {
		 	$this->widgetSchema['have_child'] = new sfWidgetFormInputCheckbox();
		 } 	
    		  if(sfConfig::get('app_form_pf_wants_children')==true)
		 {
		 	$this->widgetSchema['wants_children'] = new sfWidgetFormInputCheckbox();
		 }
           if(sfConfig::get('app_form_pf_about_me')==true)
		 {
		 	$this->widgetSchema['about_me'] = new sfWidgetFormTextarea(array(),array('style'=>'width:300px'));
		 	
		 }
		 
		 
              if(sfConfig::get('app_form_pf_about_partner')==true)
		 {
		 	$this->widgetSchema['about_partner'] = new sfWidgetFormTextarea(array(),array('style'=>'width:300px'));
		 }
      		  if(sfConfig::get('app_form_pf_best_time_of_watch')==true)
		 {
		 	$this->widgetSchema['best_time_of_watch'] = new sfWidgetFormTextarea(array(),array('width'=>400));
		 }
		 
  		 if(sfConfig::get('app_form_pf_photo')==true)
		 {
		 	$this->widgetSchema['photo'] =   new sfWidgetFormInputFile();
		 }		 
		 
		 ////Добавление ребенка и языков 
		 if(sfConfig::get('app_form_pf_add_lang')==true)
		 {
		 	$this->widgetSchema['add_language'] = new myWidgetLanguage();
		 } 	
		 
		 if(sfConfig::get('app_form_pf_add_children')==true)
		 {
		 	$this->widgetSchema['add_child'] = new myWidgetChildren();
		 } 	
		 
		 if(sfConfig::get('app_form_pf_education')==true)
		 {
		 	$this->widgetSchema['education'] = new sfWidgetFormChoice(array('expanded'=>false,'choices' => myTools::getEducation()));
		 } 		 
		 
    	 if(sfConfig::get('app_form_pf_introduction_letter')==true)
		 {
		 	$this->widgetSchema['introduction_letter'] = new sfWidgetFormTextarea(array(),array('width'=>400));
		 }		 
		 
		  if(sfConfig::get('app_form_pf_partner_age')==true)
		 {
		 	/*
		 	$this->widgetSchema['partner_age_from'] =  new sfWidgetFormChoice(array('choices' => myTools::getAge()));	
		 	$this->widgetSchema['partner_age_to'] =  new sfWidgetFormChoice(array('choices' => myTools::getAge()));	
		 	$this->widgetSchema['partner_height_from'] =  new sfWidgetFormChoice(array('choices' => myTools::getAge()));	
		 	$this->widgetSchema['partner_height_to'] =  new sfWidgetFormChoice(array('choices' => myTools::getAge()));
			*/
			$age_from=$this->getObject()->getPartnerAgeFrom();
			$age_to=$this->getObject()->getPartnerAgeTo();
			$height_from=$this->getObject()->getPartnerHeightFrom();
			$height_to=$this->getObject()->getPartnerHeightTo();
			
		   $this->widgetSchema['partner_age_from_to'] = 
		   	new myRangeAgePartnerWidget(array('partner_age_from'=>new sfWidgetFormInput(array(),array('size'=>5)),
		   										'partner_age_to'=>new sfWidgetFormInput(array(),array('size'=>5))),
		   								array('partner_age_from'=>$age_from,
		   								'partner_age_to'=>$age_to));
		   $this->widgetSchema['partner_height_from_to'] = 
		   
		   	new myRangeHeightPartnerWidget(array('partner_height_from'=>new sfWidgetFormInput(array(),array('size'=>5)),
		   										'partner_height_to'=>new sfWidgetFormInput(array(),array('size'=>5))),
		   								array('partner_height_from'=>$height_from,
		   								'partner_height_to'=>$height_to));
					 			 	
		 	
		 }		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 

		 
		/*
		 * поля не используются в ALIKE 
		 */
     
            if(sfConfig::get('app_form_pf_about_hobby')==true)
		 {
		 	$this->widgetSchema['about_hobby'] = new sfWidgetFormTextarea();
		 }

  		 if(sfConfig::get('app_form_pf_icq')==true)
		 {
		 	$this->widgetSchema['icq'] = new sfWidgetFormInput(array(),array('size'=>15));
		 } 
    	 if(sfConfig::get('app_form_pf_adres')==true)
		 {
		 	$this->widgetSchema['adres'] = new sfWidgetFormInput(array(),array('size'=>25));
		 }		      
    	 if(sfConfig::get('app_form_pf_skype')==true)
		 {
		 	$this->widgetSchema['skype'] = new sfWidgetFormInput(array(),array('size'=>15));
		 }     

    	 if(sfConfig::get('app_form_pf_have_child_partner')==true)
		 {
		 	$this->widgetSchema['have_child_partner'] = new sfWidgetFormInputCheckbox();
		 } 
      	
		 
		 //////////////////Мультики
		 
		     $this->setDefault('cmy_read',myTools::db_array_field($this->object->getMyRead())); 
		     $this->setDefault('cmy_musik',myTools::db_array_field($this->object->getMyMusik())); 
		     $this->setDefault('cmy_rest',myTools::db_array_field($this->object->getMyRest())); 
		     $this->setDefault('cmy_food',myTools::db_array_field($this->object->getMyFood())); 
		     $this->setDefault('cmy_sport',myTools::db_array_field($this->object->getMySport())); 
		     $this->setDefault('cmy_harakter',myTools::db_array_field($this->object->getMyHarakter()));
		 
		     
		     
  		 if(sfConfig::get('app_form_pf_my_read')==true)
		 {
		 	$this->widgetSchema['cmy_read'] = new sfWidgetFormChoice(array('expanded'=>'true','multiple'=>true,'choices' => myTools::getMyRead()));
		 }
         if(sfConfig::get('app_form_pf_my_musik')==true)
		 {
		 	$this->widgetSchema['cmy_musik'] = new sfWidgetFormChoice(array('expanded'=>'true','multiple'=>true,'choices' => myTools::getMyMusik()));
		 }		 
           if(sfConfig::get('app_form_pf_my_rest')==true)
		 {
		 	$this->widgetSchema['cmy_rest'] = new sfWidgetFormChoice(array('expanded'=>'true','multiple'=>true,'choices' => myTools::getMyRest()));
		 }
           if(sfConfig::get('app_form_pf_my_food')==true)
		 {
		 	$this->widgetSchema['cmy_food'] = new sfWidgetFormChoice(array('expanded'=>'true','multiple'=>true,'choices' => myTools::getMyFood()));
		 }		 		 
           if(sfConfig::get('app_form_pf_my_sport')==true)
		 {
		 	$this->widgetSchema['cmy_sport'] = new sfWidgetFormChoice(array('expanded'=>'true','multiple'=>true,'choices' => myTools::getMySport()));
		 }
         if(sfConfig::get('app_form_pf_my_harakter')==true)
		 {
		 	if($this->object->getGender()=='m')
		 	{
		 	  $this->widgetSchema['cmy_harakter'] = new sfWidgetFormChoice(array('expanded'=>'true','multiple'=>true,'choices' => myTools::getMyHarakterMan()));
		 	}
		 	else 
		 	{
		 		 $this->widgetSchema['cmy_harakter'] = new sfWidgetFormChoice(array('expanded'=>'true','multiple'=>true,'choices' => myTools::getMyHarakterWoman()));
		 	}
		 	
		 }
		 ////////////////////
		 
		 		 
		 
		 
		 /*
		  * функции админа 
		  */
		 
		 if(sfContext::getInstance()->getUser()->isAuthenticated() and sfContext::getInstance()->getUser()->hasCredential('admin'))
    {
    	 if(sfConfig::get('app_form_pf_account')==true)
		 {
    	  $this->widgetSchema['account'] =   new sfWidgetFormInput(array(),array('size'=>25));
		 }
		 
    	  if(sfConfig::get('app_use_partner')==true)
		 {
    	   $this->widgetSchema['is_partner'] =   new sfWidgetFormInputCheckbox();
		 }	
        if(sfConfig::get('app_use_partner')==true)
		 {
    	   $this->widgetSchema['partner_id'] =   new sfWidgetFormInput(array(),array('size'=>7));
		 }	 
        
     
            
		 
        $this->widgetSchema['is_top'] =   new sfWidgetFormInputCheckbox();
		 
		  if(sfConfig::get('app_form_pf_is_vip')==true)
		 {
    	   $this->widgetSchema['is_vip'] =   new sfWidgetFormInputCheckbox();
		 }
		  if(sfConfig::get('app_form_pf_is_abon')==true)
		 {
    	   $this->widgetSchema['is_abon'] =   new sfWidgetFormInputCheckbox();
		 }
		 
		 
		 
    }
     	$this->validatorSchema ['photo'] = new sfValidatorFile ( array ('required' => false, 
		'path' => sfConfig::get ( 'sf_web_dir' ) . '/uploads/users/avatar', 
		'mime_types' => 'web_images', 'max_size' => 500000, // 360 kB
        'validated_file_class' => 'sfUserAvatarValidatedFile' ) );
     	
     	$this->validatorSchema ['password'] = new sfValidatorString(array('required' => false));
     	
     	              
     
    //  $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
     
    
	     $this->widgetSchema->setLabels(
    array(
      'username'  => __('Логин'),
      'nickname'    => __('Ник'),
      'avatar'   => __('Аватар'),  
      'icq' => __('Номер ICQ'),
      'skype' => __('Номер skype'),
      'email'     => __('E-mail'),
      'password'  => __('Пароль'),
      'country' => __('Страна'),
      'gender' => __('Пол'),
      'birthday' => __('Дата рождения'),
      'password2' => __('Повтор пароля')
    )
    ); 
	    
	    
	     $this->validatorSchema->setOption('allow_extra_fields', true);
	     $this->widgetSchema->setNameFormat('user[%s]');
	     if(sfConfig::get('app_form_pf_i18n')==true)
	     {
		 $this->embedI18n(array('en', 'ru'));
	     }
	   
       
  }
}
